//
//  CATestViewController.m
//  qiche
//
//  Created by Seimei on 12-11-7.
//  Copyright (c) 2012年 iCar. All rights reserved.
//

#import "CATestViewController.h"
#import "CATest1ViewController.h"
#import "CATest2ViewController.h"
#import "CATest3ViewController.h"
@interface CATestViewController ()

@end

@implementation CATestViewController
@synthesize items = _items;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.title = NSLocalizedString(@"专业测试", @"专业测试");
        self.items = [NSArray arrayWithObjects:@"100公里每小时加速测试",@"100米加速测试",@"时速100-0公里刹车测试", nil];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
 
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return [_items count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    cell.textLabel.text = [_items objectAtIndex:indexPath.row];
    cell.textLabel.font = [UIFont systemFontOfSize:18];
    cell.accessoryType  = UITableViewCellAccessoryDisclosureIndicator;
    // Configure the cell...
    
    return cell;
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    // Navigation logic may go here. Create and push another view controller.
//    /*
//     <#DetailViewController#> *detailViewController = [[DetailViewController alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
//     // ...
//     // Pass the selected object to the new view controller.
//     [self.navigationController pushViewController:detailViewController animated:YES];
//     [detailViewController release];
//     */
    switch (indexPath.row) {
        case 0:
            //100公里每小时加速测试
        {
            CATest1ViewController *subController = [[CATest1ViewController alloc]initWithNibName:@"CATest1ViewController" bundle:nil];
            //        UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:subController];
            //        
            //        [self presentModalViewController:nav animated:YES];
            //        [nav release];
            [self.navigationController pushViewController:subController animated:YES];
            [subController release];
        }
            break;
        case 1:
            //100米加速测试
        {
            CATest2ViewController *subController = [[CATest2ViewController alloc]initWithNibName:@"CATest2ViewController" bundle:nil];
            //        UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:subController];
            //        
            //        [self presentModalViewController:nav animated:YES];
            //        [nav release];
            [self.navigationController pushViewController:subController animated:YES];
            [subController release];
        }
            break;
        case 2:
            //时速100-0公里刹车测试
        {
            CATest3ViewController *subController = [[CATest3ViewController alloc]initWithNibName:@"CATest3ViewController" bundle:nil];
            //        UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:subController];
            //        
            //        [self presentModalViewController:nav animated:YES];
            //        [nav release];
            [self.navigationController pushViewController:subController animated:YES];
            [subController release];
        }
            break;
        default:
            break;
    }
   
}

@end
